<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('薪资计算')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: container-css"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="gray-bg">
<div class="modal inmodal fade" id="myModal1" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span
                        class="sr-only">Close</span>
                </button>
                <h4 class="modal-title">选择薪资套类型</h4>
            </div>
            <div class="modal-body">
                <p>
                    <select id="pgid" name='pgid' class="form-control">
                    </select>
                </p>
            </div>
            <div class="modal-footer">
                <button type="button" id="missmodal1" class="btn btn-white" data-dismiss="modal">关闭</button>
                <button type="button" onclick="getattendORadjust()" class="btn btn-primary">确认</button>
            </div>
        </div>
    </div>
</div>

<button type="button" id="modal1" class="btn btn-primary" data-toggle="modal"
        data-target="#myModal1">选择薪资套
</button>


<div class="ui-layout-west">
    <div class="box box-main">
        <div class="box-header">
            <div class="box-title">
                <i class="fa icon-grid"></i> 薪资计算选项
            </div>
            <div class="box-tools pull-right">
                <a type="button" class="btn btn-box-tool" href="#" onclick="dept()" title="管理部门"><i
                        class="fa fa-edit"></i></a>
                <button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i
                        class="fa fa-chevron-up"></i></button>
                <button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠"><i
                        class="fa fa-chevron-down"></i></button>
                <button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新部门"><i
                        class="fa fa-refresh"></i></button>
            </div>
        </div>
        <div class="ui-layout-content">
            <div id="tree" class="ztree"></div>
        </div>
    </div>
</div>

<div class="ui-layout-center">
    <iframe id="salary" src="" scrolling="no" style="border: none;width: 100%;height: 100%"></iframe>
</div>


<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>
<th:block th:include="include :: datetimepicker-js"/>

<script th:inline="javascript">
    var pgid
    var type;
    var prefix = ctx + "salaryCalculation";
    $(function () {
        $("#modal1").hide();
        $("#xz").hide();
        $("#yjyk").hide();
        var panehHidden = false;
        if ($(this).width() < 800) {
            panehHidden = true;
        }
        $('body').layout({initClosed: panehHidden, west__size: 350});
        //getSkypayGroups();
        querySalayCalculationTree();
    });


    function querySalayCalculationTree() {
        var url = ctx + "salaryCalculation/treeData";
        var options = {
            url: url,
            expandLevel: 2,
            onClick: zOnClick
        };
        $.tree.init(options);

        /*
        src = ctx + "salaryCalculation/calculation?pgid=" + pgid;
        $("#salary").attr({
            "src": src
        });
        */
        function zOnClick(event, treeId, treeNode) {
            var src = "";
            var id = treeNode.id;
            pgid = treeNode.title;
            if (id > 105 && id < 400) {
                //计算数据跳转
                src = ctx + "salaryCalculation/calculation?pgid=" + pgid;
            } else if (id == 102) {
                //考勤数据跳转
                //src = ctx + "salaryCalculation/attend?pgid=" + pgid;
                type = "attend";
                getSkypayGroups();
            } else if (id == 103) {
                //应加应扣跳转
                //src = ctx + "salaryCalculation/adjust?pgid=" + pgid;
                type = "adjust";
                getSkypayGroups();
            } else if (id == 401) {
                //特殊人员登记跳转
                src = ctx + "specialPersonRegister";
            } else if (id == 402) {
                //特殊人员薪资登记跳转
                src = ctx + "specialPersonSalaryRegister";
            } else if (id == 403) {
                //特殊人员薪资查询跳转
                src = ctx + "specialPersonSalaryQuery";
            } else if(id == 405){
                //拜特薪资跳转
                src = ctx + "btxz";
            }
            $("#salary").attr({
                "src": src
            });
        }
    }

    /**
     * 考勤或应加应扣数据
     */
    function getattendORadjust() {
        $("#missmodal1").click();
        var src = "";
        var pgid = $("#pgid").val();
        if (type == "attend") {
            src = ctx + "salaryCalculation/attend?pgid=" + pgid;
        } else if (type == "adjust") {
            src = ctx + "salaryCalculation/adjust?pgid=" + pgid;
        }
        $("#salary").attr({
            "src": src
        });
    }

    /**
     * 获取薪资套列表
     */
    function getSkypayGroups() {
        var html = "";
        $.ajax({
            async: false,
            url: ctx + "salaryCalculation/getSkypayGroups",
            data: {},
            type: "post",
            dataType: "json",
            success: function (data) {
                $("#pgid").empty();
                var arry = data;
                for (var i = 0; i < arry.length; i++) {
                    html += "<option value='"
                        + arry[i].id
                        + "'>"
                        + arry[i].title
                        + "</option>";
                }
                $("#pgid").append(html);
                $("#modal1").click();
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert("错误,请联系管理员,错误信息:" + textStatus);
            }
        });
    }



</script>
</body>
</html>